import request from "@/plugins/request";
import apiPath from "./config/dev";
import qs from "qs";

const axiosPost = (url, data, headers) => {
  let config = {
    url,
    method: "post",
    data
  };

  if (headers) {
    config.headers = headers;
  }
  return request(config);
};
const axiosGet = (url, params, responseType) => {
  if (responseType) {
    return request({
      url,
      method: "get",
      params,
      responseType
    });
  }
  return request({
    url,
    method: "get",
    params
  });
};
const axiosPut = (url, params, data) => {
  return request({
    url,
    method: "put",
    params,
    data
  });
};
const axiosDelete = (url, params) => {
  return request({
    url,
    method: "delete",
    params
  });
};

// scada-储能系统监视接口
const scadaPath = apiPath.scada.url;
let storePower = "scada/Storecn";
let scada = "scada/power";
let caes = "scada/caes";
let charge = "scada/charge";

export function cdfdpawday(data) {
  return axiosGet(`${scadaPath}/${storePower}/cdfdpawday`, data);
}

//储能运行指标
export function StoreIndex() {
  return axiosGet(`${scadaPath}/${storePower}/StoreIndex`);
}

//母线数据接口
export function StoreCell() {
  return axiosGet(`${scadaPath}/${storePower}/StoreCell`);
}

let windPower = "scada/windPlant";

//风电信息总览
export function windSystemOverview() {
  return axiosGet(`${scadaPath}/${windPower}/windSystemOverview`);
}

export function windStatusSystemOverview() {
  return axiosGet(`${scadaPath}/${windPower}/windStatusSystemOverview`);
}

//风电环境参数信息
export function windEnvOverview() {
  return axiosGet(`${scadaPath}/${windPower}/windEnvOverview`);
}

//风电日发电功率曲线图
export function windPlantCurve() {
  return axiosGet(`${scadaPath}/${windPower}/windPlantCurve`);
}

//风机系统图
export function megInfluxlineSystemDiagram() {
  return axiosGet(`${scadaPath}/${windPower}/megInfluxlineSystemDiagram`);
}

/**
 冷热管网
 */
let coldHot = "scada/hotscadaHotColdPipeWorkControllerColdPipeWork";

export function hotColdPipeWorkSystemOverview() {
  return axiosGet(`${scadaPath}/${coldHot}/hotColdPipeWorkSystemOverview`);
}

export function hotColdPipeWorkPowerforEnergySupply() {
  return axiosGet(
    `${scadaPath}/${coldHot}/hotColdPipeWorkPowerforEnergySupply`
  );
}

export function hotColdPipeWorkSystemDiagram() {
  return axiosGet(`${scadaPath}/${coldHot}/hotColdPipeWorkSystemDiagram`);
}

/**
 冷热电三联
 */
let coldHotEle = "electricitysupply";

export function coldHotEleDetails() {
  return axiosGet(`${scadaPath}/${coldHotEle}/hotColdPipeWorkSystemOverview`);
}

export function getPowerChartData() {
  return axiosGet(
    `${scadaPath}/${coldHotEle}/selectPowercauserColdhotelectricity`
  );
}

export function getHotColdPipeDetails() {
  return axiosGet(`${scadaPath}/${coldHotEle}/hotColdPipeWorkcaheatengine`);
}

/**
 * 分布式光伏监测
 */

let distributedPhotovoltaic = "scada/pv";

export function runIndex() {
  return axiosGet(`${scadaPath}/${distributedPhotovoltaic}/runIndex`);
}

export function getEnv() {
  return axiosGet(`${scadaPath}/${distributedPhotovoltaic}/env`);
}

export function listPower() {
  return axiosGet(`${scadaPath}/${distributedPhotovoltaic}/listPower`);
}

export function listData() {
  return axiosGet(`${scadaPath}/${distributedPhotovoltaic}/listData`);
}

export function getAll() {
  return axiosGet(`${scadaPath}/${distributedPhotovoltaic}/getAll`);
}

/**
 *中央空调
 */

let centerAir = "scada/aircondition";

export function getIesmefcacInfo() {
  return axiosGet(`${scadaPath}/${centerAir}/getIesmefcacInfo`);
}

export function powergraph() {
  return axiosGet(`${scadaPath}/${centerAir}/powergraph`);
}

export function loadAirHost() {
  return axiosGet(`${scadaPath}/${centerAir}/loadAirHost`);
}

/* 
	电能质量监测
	 
	 */
export function equipType() {
  return axiosGet(`${scadaPath}/${scada}/equipType`); //设备类型查询
}

export function archives(data) {
  return axiosGet(`${scadaPath}/${scada}/archives`, data); //设备名称查询
}

export function monitoring(data) {
  return axiosGet(`${scadaPath}/${scada}/monitoring`, data); //电压偏差监测，电压波动监测，电压谐波畸变率
}

export function threephase(data) {
  return axiosGet(`${scadaPath}/${scada}/threephase`, data); //三相不平衡曲线
}

//压缩空气储能

export function getSystemOverview() {
  return axiosGet("${scadaPath}/${caes}//getSystemOverview");
}

export function getPowerCurveDay() {
  return axiosGet(`${scadaPath}/${caes}/getPowerCurveDay`);
}

export function getEnergyStorageParameters() {
  return axiosGet(`${scadaPath}/${caes}/getEnergyStorageParameters`);
}

//充电系统监测

export function getPowerDay() {
  return axiosGet(`${scadaPath}/${charge}/getPowerDay`);
}

export function chargingInfo() {
  return axiosGet(`${scadaPath}/${charge}/chargingInfo`);
}

export function sumSystemInfo() {
  return axiosGet(`${scadaPath}/${charge}/sumSystemInfo`);
}

//任务调度
const iescollecttask = "scada/iescollecttask";
// 客户名称（下拉框）
export function getIescollecttaskCustId() {
  return axiosGet(`${scadaPath}/${iescollecttask}/getCustId`);
}
// 采集对象（下拉框）
export function getIescollecttaskDevid(params = {}) {
  return axiosGet(`${scadaPath}/${iescollecttask}/getDevid`, params);
}

// 优先级设置（列表）
export function getIescollecttaskShow(params = {}) {
  return axiosGet(`${scadaPath}/${iescollecttask}/show`, params);
}

// - 设置-降级
export function putIescollecttaskReduceLevel(data = {}) {
  return axiosPut(`${scadaPath}/${iescollecttask}/reduceLevel`, data);
}

// - 设置-升级
export function putIescollecttaskPlusLevel(data = {}) {
  return axiosPut(`${scadaPath}/${iescollecttask}/plusLevel`, data);
}

// - 设置-添加任务
export function postInsertIescollecttask(data = {}) {
  return axiosPost(`${scadaPath}/${iescollecttask}/insertIescollecttask`, data);
}

//告警监视
const warning = "scada/warning";

// - 设备类型查询
export function getSWarningCust(params = {}) {
  return axiosGet(`${scadaPath}/${warning}/getcust`, params);
}

const alarms = "scada/alarms";

// - 区域
export function getAlarmOrgtree(params = {}) {
  return axiosGet(`${scadaPath}/${alarms}/orgtree`, params);
}

// - 告警类型
export function getAlarmType(params = {}) {
  return axiosGet(`${scadaPath}/${alarms}/alarmType`, params);
}

// - 告警列表
export function getAlarmMonitor(params = {}) {
  return axiosGet(`${scadaPath}/${alarms}/monitor`, params);
}

// 告警参数
// - 测量点名称
export function getSWarningMeaspoint(params = {}) {
  return axiosGet(`${scadaPath}/${warning}/measpoint`, params);
}

// - 告警类型
export function getSWarningBCode(params = {}) {
  return axiosGet(`${scadaPath}/${warning}/bCode`, params);
}

// - 触发次数
export function getSWarningAlarmCount(params = {}) {
  return axiosGet(`${scadaPath}/${warning}/alarmCount`, params);
}

// - 触发周期
export function getSWarningPeriod(params = {}) {
  return axiosGet(`${scadaPath}/${warning}/period`, params);
}

// - 测量数据项
export function getSWarningCpData(params = {}) {
  return axiosGet(`${scadaPath}/${warning}/cpData`, params);
}
// - 告警项名称
export function getSWarningName(params = {}) {
  return axiosGet(`${scadaPath}/${warning}/swarningName`, params);
}
// - 客户站点
export function getSWarningCsite(params = {}) {
  return axiosGet(`${scadaPath}/${warning}/csite`, params);
}

// - 分页
export function getSWarningParam(params = {}) {
  return axiosGet(`${scadaPath}/${warning}/param`, params);
}

// - 根据id查询告警参数配置
export function getSWarningParas(params = {}) {
  return axiosPost(`${scadaPath}/${warning}/getSWarningParas`, params);
}

// - 根据id查询告警参数配置
export function postSWarningParaSaveOrUpdate(params = {}) {
  return axiosPost(`${scadaPath}/${warning}/sWarningParaSaveOrUpdate`, params);
}

//分布式光伏
let pv = "scada/pv";

export function getFbsData() {
  return axiosGet(`${scadaPath}/${pv}/getFbsData`);
}

export function twoLine() {
  return axiosGet(`${scadaPath}/${pv}/twoLine`);
}

export function getHlData() {
  return axiosGet(`${scadaPath}/${pv}/getHlData`);
}

//cpshome
let cpshome = "scada/cpsmonitor";

export function getCustInfo() {
  return axiosGet(`${scadaPath}/${cpshome}/getCustInfo`);
}

export function getEnergyInfo() {
  return axiosGet(`${scadaPath}/${cpshome}/getEnergyInfo`);
}

export function getEleday() {
  return axiosGet(`${scadaPath}/${cpshome}/getEleday`);
}

export function getAlarmInfo() {
  return axiosGet(`${scadaPath}/${cpshome}/getAlarmInfo`);
}

export function getLoadRate() {
  return axiosGet(`${scadaPath}/${cpshome}/getLoadRate`);
}

// 用户操作首页
let userControlHome = "scada/userOperation";

export function selectBaseInfosByCustId() {
  return axiosGet(`${scadaPath}/${userControlHome}/selectBaseInfosByCustId`);
}

export function getSubstationsAll() {
  return axiosGet(`${scadaPath}/${userControlHome}/getSubstationsAll`);
}

export function listEquipTypeNoPaging() {
  return axiosGet(`${scadaPath}/${userControlHome}/listEquipTypeNoPaging`);
}
export function selectUserOperationWebmapCustSite(data) {
  return axiosGet(
    `${scadaPath}/${userControlHome}/selectUserOperationWebmapCustSite`,
    data
  );
}

export function userControlList(data) {
  return axiosGet(`${scadaPath}/${userControlHome}/list`, data);
}
export function selectUserOperationControl(data) {
  return axiosGet(
    `${scadaPath}/${userControlHome}/selectUserOperationControl`,
    data
  );
}
export function safetyVerificationOperation(data) {
  let headers = {
    "content-type": "application/json;charset=UTF-8"
  };
  return axiosPost(
    `${scadaPath}/${userControlHome}/safetyVerificationOperation`,
    JSON.stringify(data),
    headers
  );
}
export function controlSurfaceOperation(data) {
  let headers = {
    "content-type": "application/json;charset=UTF-8"
  };
  return axiosPost(
    `${scadaPath}/${userControlHome}/controlSurfaceOperation`,
    JSON.stringify(data),
    headers
  );
}

export function batchControlBatchInsert(data) {
  let headers = {
    "content-type": "application/json;charset=UTF-8"
  };
  return axiosPost(
    `${scadaPath}/${userControlHome}/batchControlBatchInsert`,
    JSON.stringify(data),
    headers
  );
}

export function batchControlExecute(data) {
  let headers = {
    "content-type": "application/json;charset=UTF-8"
  };
  return axiosPost(
    `${scadaPath}/${userControlHome}/batchControlExecute`,
    JSON.stringify(data),
    headers
  );
}

export function selectDeviceBatchControl(data) {
  return axiosGet(
    `${scadaPath}/${userControlHome}/selectDeviceBatchControl`,
    data
  );
}

// 安全校验配置
const safeCheck = "scada/Storecn";

export function getSafeCheckSite() {
  return axiosGet(`${scadaPath}/${safeCheck}/SiteW`);
}

export function getSafeCheckArea() {
  return axiosGet(`${scadaPath}/${safeCheck}/AreaW`);
}

export function getSafeCheckDeviceType() {
  return axiosGet(`${scadaPath}/${safeCheck}/TypeW`);
}

export function getSafeChecklist(data) {
  let headers = {
    "content-type": "application/json;charset=UTF-8"
  };
  return axiosPost(
    `${scadaPath}/${safeCheck}/listW`,
    JSON.stringify(data),
    headers
  );
}

export function updateControlgua(data) {
  let headers = {
    "content-type": "application/json;charset=UTF-8"
  };
  return axiosPost(
    `${scadaPath}/${safeCheck}/updateControlgua`,
    JSON.stringify(data),
    headers
  );
}

export function updateControlDisgua(data) {
  let headers = {
    "content-type": "application/json;charset=UTF-8"
  };
  return axiosPost(
    `${scadaPath}/${safeCheck}/updateControlDisgua`,
    JSON.stringify(data),
    headers
  );
}
export function updateControlcheck(data) {
  let headers = {
    "content-type": "application/json;charset=UTF-8"
  };
  return axiosPost(
    `${scadaPath}/${safeCheck}/updateControlcheck`,
    JSON.stringify(data),
    headers
  );
}
export function updateControlDischeck(data) {
  let headers = {
    "content-type": "application/json;charset=UTF-8"
  };
  return axiosPost(
    `${scadaPath}/${safeCheck}/updateControlDischeck`,
    JSON.stringify(data),
    headers
  );
}

// 控制反演
// - 操作列表
export function getControlinversionSelectiesscaopinfo(params) {
  const { currentPage, pageSize, ...data } = params;
  return axiosPost(
    `${scadaPath}/controlinversion/selectiesscaopinfo?currenPage=${currentPage}&pageSize=${pageSize}`,
    data
  );
}
// - 设备类型
export function getControlinversionSelectOEquipType(params) {
  return axiosGet(`${scadaPath}/controlinversion/selectOEquipType`, params);
}
// - 反演
export function getControlinversionSelectInversionVo(params) {
  return axiosGet(`${scadaPath}/controlinversion/selectInversionVo`, params);
}

// 策略管理
// 事件区域
export function getArea(params) {
  return axiosGet(`${scadaPath}/${pv}/getArea`, params);
}
// 策略管理列表
export function getTacticsList(params) {
  return axiosGet(`${scadaPath}/${pv}/getTacticsList`, params);
}
// 查询单个事件
export function getSelectTactics(params) {
  return axiosGet(`${scadaPath}/${pv}/selectTactics`, params);
}

// 修改单个事件
export function updateTactics(data) {
  return axiosPost(`${scadaPath}/${pv}/updateTactics`, data);
}
// 下发
export function handleIssue(data) {
  return axiosPost(`${scadaPath}/${pv}/issue`, data);
}

// 应急控制
const emergency = "scada/emergency";
// 控制列表
export function getEmergencyList(data) {
  return axiosGet(`${scadaPath}/${emergency}/dispatchList`, data);
}
// 用户列表
export function getCustomerList(data) {
  return axiosGet(`${scadaPath}/${emergency}/getCustomer`, data);
}
// 设备列表
export function getEquipList(data) {
  return axiosGet(`${scadaPath}/${emergency}/queryEquip`, data);
}
// 控制列表新增
export function addEmergency(data) {
  return axiosPost(`${scadaPath}/${emergency}/add`, data);
}
// 控制列表修改
export function deleteEmergency(data) {
  return axiosDelete(`${scadaPath}/${emergency}/delete`, data);
}
// 控制列表修改
export function updateEmergency(data) {
  return axiosPut(`${scadaPath}/${emergency}/update`, {}, data);
}
// 控制列表查询
export function getEmergencySelect(data) {
  return axiosGet(`${scadaPath}/${emergency}/select`, data);
}
// 控制执行
export function executeEmergency(data) {
  const { controlsId, instructId, ...params } = data;
  return axiosPost(
    `${scadaPath}/${emergency}/execute?controlsId=${controlsId}&instructId=${instructId}`,
    params
  );
}
// 导出
export function exportEmergency(data, responseType) {
  return axiosGet(`${scadaPath}/${emergency}/export`, data, responseType);
}

// 控制查看
const controlView = "scada/controlView";
// 用户列表
export function getControlViewCustId(data) {
  return axiosGet(`${scadaPath}/${controlView}/getCustId`, data);
}
// 设备列表
export function getControlViewDevId(data) {
  return axiosGet(`${scadaPath}/${controlView}/getDevid`, data);
}
// 设备类型列表
export function getControlViewDevType(data) {
  return axiosGet(`${scadaPath}/${controlView}/getDevType`, data);
}
// 列表
export function getControlViewList(data) {
  return axiosGet(`${scadaPath}/${controlView}/show`, data);
}
// 解除
export function relieveControlView(data) {
  return axiosPut(`${scadaPath}/${controlView}/relieve`, data);
}
// 执行
export function implementControlView(data) {
  return axiosPut(`${scadaPath}/${controlView}/implement`, data);
}
// 导出
export function exportControlView(data, responseType) {
  return axiosGet(`${scadaPath}/${controlView}/export`, data, responseType);
}
